<?php 
session_start();
include_once "../db_connect.php"; // Connect to the database
$type = mysql_real_escape_string($_POST['type']);
if($_POST["type"] == "")
{
 echo "important variable is missing";
 exit();
}
else
{
	
	$forum_section_id = mysql_real_escape_string($_POST['forum_section_id']);
	$forum_section_title = mysql_real_escape_string($_POST['forum_section_title']);
	
	$reply_body = mysql_real_escape_string($_POST['reply_body']);
	$type_violation = $_POST['type_violation'];
	$others = $_POST['others'];
	$tbl_id = $_POST['tbl_id'];
	//check the type.
	if($type == "a")
	{
	$sql = mysql_query("SELECT * FROM forum_posts WHERE id = '$tbl_id'");
	$numrows = mysql_num_rows($sql);
	if($numrows <1)
		{
		echo "Wala nmn ganyan eh";
		exit();
		}
		else
		{
		mysql_query("UPDATE forum_posts set closed='1' WHERE id='$tbl_id'");
		}
	}
	else if($type == "b")
	{
	$forum_thread_id = mysql_real_escape_string($_POST['forum_thread_id']);
	$forum_thread_title = mysql_real_escape_string($_POST['forum_thread_title']);
	$member_reply_id = mysql_real_escape_string($_POST['reply_author_id']);
	$sql = mysql_query("SELECT * FROM forum_posts WHERE id = '$tbl_id'");
	$numrows = mysql_num_rows($sql);
		if($numrows <1)
		{
		echo "There's no thread like that";
		exit();
		}
		else
		{
		mysql_query("UPDATE forum_posts set closed='1' WHERE id='$tbl_id'");
		
		                                                        
		echo "successfully deleted";
	
		}
	}

}


?>